{layout name="pub/pub_css_js" /}
<script type="text/javascript" src="/static/js/vue2.5.1.js"></script>
<script src="/static/js/axios.min.js"></script>
<script type="text/javascript" src="__STATIC__/admin_page/lib/jquery/1.9.1/jquery.min.js"></script>
<script src="/static/js/jquery.base64.js"></script>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 服务商<span
        class="c-gray en">&gt;</span> 服务商列表 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px"
                                               href="/admin/Service/Servicelist" title="刷新"><i
        class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container" id="app">
    <a href="javascript:;" @click="member_add" class="btn btn-primary radius"> 增加服务商</a>
    <div class="text-c">
        服务商状态:<span class="select-box inline">
		<select name="status" id="status" v-model="status" class="select">
			<option value="0">待审核</option>
			<option value="1">审核通过</option>
			<option value="2">审核拒绝</option>
			<option value="3">未填写完成</option>
		</select>
		</span>
        <input type="text" name="keyword" id="keyword" v-model="keyword" placeholder=" 服务商名称" style="width:250px"
               class="input-text">
        <input type="text" name="user_mobile"  v-model="user_mobile" placeholder=" 注册手机号" style="width:160px"
               class="input-text">
        <input type="text" name="user_email"  v-model="user_email" placeholder=" 注册邮箱" style="width:160px"
               class="input-text">
        <button name="" @click="goComment" class="btn btn-success" type="submit"><i class="Hui-iconfont">&#xe665;</i>
            搜服务商
        </button>
    </div>
    <div class="mt-20">
        <table class="table table-border table-bordered table-bg table-hover table-sort table-responsive">
            <thead>
            <tr class="text-c">

                <th width=160">服务商列表</th>
                <th>公司名称</th>
                <th>服务号名称</th>
                <th>手机号</th>
                <th>邮箱</th>
                <th>服务对象</th>
                <th>服务区域</th>
                <th>省</th>
                <th>城市</th>
                <th width="60">审核状态</th>
                <th width="200">预览提交信息</th>
                <th width="200">操作</th>
            </tr>
            </thead>
            <tbody>

            {foreach $data as $vo}
            <tr class="text-c">
                <td>{$vo['service_id']}</td>
                <td>{$vo['company_name']}</td>
                <td>{$vo['service_name']}</td>
                <td>{$vo['user_mobile']}</td>
                <td>{$vo['user_email']}</td>
                <td>
                    {if condition="$vo['service_object'] eq 1"/}进口商
                    {elseif condition="$vo['service_object'] eq 2"/} 出口商
                    {elseif condition="$vo['service_object'] eq 4"/} 进出口商
                    {else /} 其他
                    {/if}
                </td>
                <td> {if condition="$vo['service_region'] eq 1"/}国内
                    {else /} 国外
                    {/if}
                </td>
                <td>{$vo['province']}</td>
                <td>{$vo['city']}</td>
                <td>{if condition="($vo['service_info_status'] == 1 || $vo['service_info_status'] == 5)"}
                    审核通过
                    {elseif condition="$vo['service_info_status'] eq 2"/}
                    审核拒绝
                    {elseif condition="$vo['service_info_status'] eq 0"/}
                    待审核
                    {else /} 在填写中....
                    {/if}
                </td>
                <td class="text-l">
                    <a href="javascript:void(0)" class="btn btn-primary radius"
                       @click="openDetail('{$vo[\'service_id\']}')">基本信息</a>
                    <a href="javascript:void(0)" class="btn  btn-primary radius "
                       @click="openeDetailProve('{$vo[\'service_id\']}')">证明信息</a>
                   <a href="javascript:void(0)" class="btn  btn-primary radius "
                       @click="openDetailEidt('{$vo[\'service_id\']}')">编辑</a>
                </td>
                <td class="f-14 td-manage">
                    {if condition="($vo['service_info_status'] == 0 )"}
                    <a href="javascript:void(0)" class="btn btn-primary radius"
                       @click="To_Examine('{$vo[\'service_id\']}',1)">通过</a>
                    <a href="javascript:void(0)" class="btn btn-danger radius"
                       @click="show_refuse('{$vo[\'service_id\']}')">拒绝</a>
                    <a href="javascript:void(0)" class="btn btn-danger radius"
                       @click="resetPassword('{$vo[\'service_id\']}')">重置密码</a>
                    {else /}
                    <a href="javascript:void(0)" class="btn btn-danger radius"
                       @click="resetPassword('{$vo[\'service_id\']}')">重置密码</a>
                    <a href="javascript:void(0)" class="btn btn-warning radius"
                       @click="Deluser('{$vo[\'service_id\']}')">删除</a>
                    {/if}
                </td>
            </tr>
            {/foreach}
            </tbody>

        </table>
        <div class="mt-20">
            {$data->render()}
        </div>
    </div>
    <div id="refuse" v-show="refuse" class="custom-layer"  >
        <form action="">
            拒绝步骤:<select name="refuse_step" v-model="refuse_step">
            <option :value="item.value" v-for="item in options">{{item.label}}</option>
        </select>
        </form>
        请输入拒绝原因:
        <ul>
            <li v-for='(list,index) in lists'>
                <input v-model="list.value" class="input-text" style="width: 260px;margin-top: 5px"  placeholder="请输入拒绝原因"/>
                <button v-on:click='lists.splice(index, 1)'  class="btn btn-danger radius" >删除</button>
            </li>
        </ul>
        <button @click='addNewList' class="btn btn-warning radius" style="margin-top: 5px" >添加拒绝原因</button>
        <button @click='ExamineService' class="btn btn-success radius" >提交</button>
        <button @click='Cancel_Res' class="btn btn-danger radius">取消</button>
    </div>
</div>
<style>
    .custom-layer{
        margin:0 auto;
        background: #5eb5e0;
        width: 80%;
        padding: 10px;
        -webkit-border-radius: 10px;
        -moz-border-radius: 10px;
        border-radius: 10px;
        font: 16px "Microsoft YaHei UI";
    }
</style>
<script >
    new Vue({
        el: '#app',
        data: {
            audit_msg: '',
            refuse: false,
            newAddText: '',
            service_id: '',
            status: "{$search['status']}",
            keyword: "{$search['keyword']}",
            user_mobile: "{$search['user_mobile']}",
            user_email: "{$search['user_email']}",
            lists: [
                {value: ''},
            ],
            options: [
                {
                    value: '2',
                    label: '步骤二(基本信息)'
                }, {
                    value: '3',
                    label: '步骤三(证明信息)'
                }],
            refuse_step: 4
        },
        created() {
            this.refuse_step = this.options[0].value;
        },
        methods: {
            goComment() {
                window.location.href = '/admin/Service/Servicelist?status=' + this.status + '&keyword=' + this.keyword+ '&user_mobile=' + this.user_mobile+ '&user_email=' + this.user_email;
            },

            Cancel_Res() {
                this.refuse = false;
            },
            To_Examine(service_id, status) {
                console.log(service_id)
                console.log(status)
                if (status == 1) {
                    layer.confirm('确定要审核成功吗？', {
                        btn: ['确定', '取消'] //按钮
                    }, function () {
                        axios.post('/admin/Service/ExamineService',
                            {
                                service_id: service_id,
                                service_info_status: status,
                                request_type: 'h5',
                                audit_msg: this.audit_msg,
                                refuse_step: this.refuse_step
                            }
                        ).then(response => {
                            if (response.data.status == 200) {
                                this.audit_msg = '';
                                this.refuse_step = '';
                                window.location.reload();
                            } else {
                                layer.alert(response.data.msg)
                            }
                        })
                    });
                } else {
                    layer.open({
                        type: 2,
                        title: '审核拒绝填写原因',
                        shadeClose: true,
                        shade: 0.8,
                        area: ['800px', '70%'],
                        content: '/admin/Service/ExamineServiceRefuse?service_id=' + service_id,
                        end: function () {
                            window.location.reload();
                        }
                    });
                }
            },
            openDetail(service_id) {
                layer.open({
                    type: 2,
                    title: '预览基本信息',
                    shadeClose: true,
                    shade: 0.8,
                    area: ['800px', '70%'],
                    content: '/admin/Service/ServiceDetail?service_id=' + service_id
                });
            },
            openeDetailProve(service_id) {
                layer.open({
                    type: 2,
                    title: '预览证明信息',
                    shadeClose: true,
                    shade: 0.8,
                    area: ['800px', '70%'],
                    content: '/admin/Service/ServiceDetailProve?service_id=' + service_id
                });
            },
            openDetailEidt(service_id){
                layer.open({
                    type: 2,
                    title: '编辑文章',
                    shadeClose: true,
                    shade: 0.8,
                    area: ['800px', '70%'],
                    content: '/admin/Service/editServiceInfo?service_id=' + service_id,
                    end: function () {
                        window.location.reload();
                    }
                });
            },
            addNewList: function () {
                this.lists.push({
                    value: this.newAddText
                })
                this.newAddText = ''
            },
            show_refuse: function (service_id) {
                this.service_id = service_id
                this.refuse = true;
            },
            ExamineService: function () {
                if (this.lists[0].value.length > 1) {
                    axios.post('/admin/Service/ExamineService',
                        {
                            service_id: this.service_id,
                            service_info_status: 2,
                            request_type: 'h5',
                            error_message: this.lists,
                            refuse_step: this.refuse_step
                        }
                    ).then(response => {
                        if (response.data.status == 200) {
                            this.refuse = false;
                            this.lists = {value: ''};
                            this.refuse_step = '';
                            location.reload()
                        } else {
                            layer.alert(response.data.msg)
                        }
                    })
                } else {
                    layer.alert('请填写拒绝原因!')
                }

            },

            //重置密码
            resetPassword: function (service_id) {
                //var service_id = 'S_154805333158481265';
                layer.confirm('确定要重置该服务商密码吗？', {
                    btn: ['确定', '取消'] //按钮
                }, function () {
                    axios.post('/admin/Service/resetPassword',
                        {
                            service_id: service_id,
                            service_info_status: status,
                            request_type: 'h5',
                            audit_msg: this.audit_msg,
                            refuse_step: this.refuse_step
                        }
                    ).then(response => {
                        if (response.data.status == 200) {
                            this.audit_msg = '';
                            this.refuse_step = '';
                            window.location.reload();
                        } else {
                            layer.alert(response.data.msg)
                        }
                    })
                });
            },
            member_add: function () {
                layer.open({
                    type: 2,
                    title: '增加服务商',
                    shadeClose: true,
                    shade: 0.8,
                    area: ['800px', '70%'],
                    content: '/admin/Service/add'
                });
            },
            Deluser:function (service_id) {
                layer.confirm('确定要删除服务商？', {
                    btn: ['确定', '取消'] //按钮
                }, function () {
                    axios.post('/admin/Service/del',
                        {
                            service_id: service_id,
                            request_type: 'h5',
                        }
                    ).then(response => {
                        if (response.data.status == 200) {
                            window.location.reload();
                        } else {
                            layer.alert(response.data.msg)
                        }
                    })
                });
            }
        }
    });
</script>



